<template>
  <div class="box5">
    <div class="title">
      <p>未来七天游客访问量趋势</p>
      <img src="../../images/dataScreen-title.png" alt="">
    </div>

    <div class="chart" ref="line"></div>
  </div>
</template>

<script setup>
import {onMounted, ref} from 'vue';
import * as echarts from 'echarts'

const line = ref()
onMounted(() => {
  const myChart = echarts.init(line.value)
  const option = {
    grid: {
      left: 60,
      top: 0,
      right: 20,
      bottom: 30
    },
    tooltip: {
      trigger: 'axis'
    },
    xAxis: {
      type: 'category',
      axisLine: { show: true },
      boundaryGap: false, // 坐标轴两边留白策略
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    },
    yAxis: {
      type: 'value',
      axisLine: { show: true },
      splitLine: { show: false },
    },
    series: [{
      data: [200, 1010, 500, 1300, 650, 1100, 500],
      type: 'line',
      smooth: true,
      // 区域填充样式
      areaStyle: {
        color: {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [{
            offset: 0,
            color: 'pink'
          }, {
            offset: 1,
            color: 'blue'
          }],
          global: false // 缺省为 false
        }
      }
    }]
  }
  myChart.setOption(option)
  myChart.resize()
})

</script>

<style scoped xml:lang="scss">
.box5 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 98% 100%;
  margin: 0 20px;

  .title {
    margin-left: 10px;

    p {
      color: white;
      font-size: 22px;
    }
  }

  .chart {
    height: calc(100% - 65px);
    margin: 10px;
  }
}

</style>